put FieldToMenuChoice(a,b+1,myField,arbitrary) into msg
set the hilite of the target to false
end mousedown
-- part contents for background part 17
----- text -----
FieldToMenuChoice
-- part contents for background part 18
----- text -----
Mike Gleason Jr.
-- part contents for background part 19
----- text -----
XFCN
-- part contents for background part 20
----- text -----
put FieldToMenuChoice(top,left,field [,itemName/num])
-- part contents for background part 21
----- text -----
This is the answer for those times when you need a fairly large menu, and your menustring would exceed 255 characters. Now you can just pass a field, and this will convert each line into a menu item. However there are a few catches:
.
1: The maximum amount of items is limited to 100, and the maximum length for an item is 50 characters. Any item over 50 will be truncated to 50 characters.
2: There is a small bug that requires that you have an empty line in front of the list. It won't convert the first line properly, but you can get around this by simply inserting a blank line in your field, or by concatenating a return in front of it, like this:
put Return&MyField into MyField
.
Now I'll explain the paramters:
top, left: The location that the popupmenu box will appear, in global screen coordinates. An ideal place to put it is below a transparent button. See the example's script to get an idea.
field: the field of information to convert into a menu. Don't forget to add the extra return at the beginning!
itemName/num: This is an optional parameter. If you don't pass anything, you'll get what you expected back, the name of the item that was selected. If you DO pass something, you'll get back it's item number in the menu instead.
When you pass the field, note that you can add in those cryptic metacharacters to change the menu's appearance, and that you can pass more than one item on a line. For example your field might look like this:
item one; item two -- passing two items on same line, separated by ;
<Bitem three -- this will appear in BoldFace in the menu,
and will appear as "item three" NOT ">Bitem three"
Likewise, you WILL NOT get ">Bitem three" back as the result, but what you really want, "item three".
.
One more thing, if the user pulls down the menu but doesn't select anything, a null string (or zero if you're getting the item number) will be returned, so make sure you check for that.